<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>添加任务</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/resource/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/resource/css/mylay.css">
</head>
<body>
    <div style="padding: 20px; background-color: #F2F2F2;">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body">
                        <form class="layui-form" lay-filter="task_add">
<!--                            <div class="layui-form-item">-->
<!--                                <label class="layui-form-label">碎片分类</label>-->
<!--                                <div class="layui-input-inline">-->
<!--                                    <select name="task_class" id="task_model_id" lay-verify="required" lay-search="" lay-filter="task_model_id">-->
<!--                                        <option value="">请选择分类</option>-->
<!--                                        {foreach $taskClass as $key=>$value }-->
<!--                                        <option value="{$value.id}">{$value.lang}-{$value.group_name}</option>-->
<!--                                        {/foreach}-->
<!--                                    </select>-->
<!--                                </div>-->
<!--                            </div>-->
                            <!-- <div class="layui-form-item">
                                <label class="layui-form-label">语言</label>
                                <div class="layui-input-inline">
                                     <select name="lang" lay-verify="required" lay-search="">
                                     {foreach :config('custom.lang') as $key=>$value }
                                        <option value="{$key}">{$value}</option>
									 {/foreach}
                                    </select>
                                </div>
                            </div> -->
                            <div class="layui-form-item">
                                <label class="layui-form-label">发布者</label>
                                <div class="layui-input-block">
                                    <input type="text"  autocomplete="off" placeholder="" class="layui-input" value="{$nftInfo['username']}" readonly>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">NFT文件</label>
                                <div class="layui-input-inline">
                                    <div class="layui-upload">
                                        <!-- <button type="button" class="layui-btn" id="file">
                                            <i class="layui-icon">&#xe67c;</i>上传
                                        </button> -->
                                        <div class="layui-upload-list">
                                            <img class="layui-upload-img" id="file_image" style="width:150px;" src="{$nftInfo['file']}">
                                            <p id="file_image_text"></p>
                                        </div>
                                    </div>
                                    <input type="hidden"  id="file_input" value="{$nftInfo['file']}" placeholder="" autocomplete="off" class="layui-input" readonly>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">NFT名称</label>
                                <div class="layui-input-block">
                                    <input type="text"  autocomplete="off" placeholder="" class="layui-input" value="{$nftInfo['name']}" readonly>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">类型</label>
                                <div class="layui-input-inline">
                                    <select  lay-verify="required" lay-search="" readonly name='credit_type'>
                                        {foreach $creditType as $key=>$value }
                                        <option value="{$value['id']}" {if $value['id'] == $nftInfo['credit_type']}selected='selected'{/if}>{$value['name']}</option>
                                        {/foreach}
                                    </select>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">份额</label>
                                <div class="layui-input-inline">
                                    <input type="number" name="total_number" value="1" autocomplete="off" placeholder="请输入份额" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">限购</label>
                                <div class="layui-input-inline">
                                    <input type="number" name="person_time" value="1" autocomplete="off" placeholder="请输入限购次数" class="layui-input">
                                </div>
                                <div class="layui-form-mid layui-word-aux">次/人</div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">预售价格</label>
                                <div class="layui-input-inline">
                                    <input type="number" name="release_price" value="0" autocomplete="off" placeholder="请输入价格" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">挂牌价格</label>
                                <div class="layui-input-inline">
                                    <input type="number" name="reward_price" value="0" autocomplete="off" placeholder="请输入价格" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">回购价格</label>
                                <div class="layui-input-inline">
                                    <input type="number" name="recovery_price" value="0" autocomplete="off" placeholder="请输入价格" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">结束时间(小时)</label>
                                <div class="layui-input-inline">
                                    <input type="number" name="cost_hours" autocomplete="off" placeholder="请输入结束时间" class="layui-input" >
                                </div>
                            </div>




<!--
                            <div class="layui-form-item">
                                <label class="layui-form-label">任务标题</label>
                                <div class="layui-input-block">
                                    <input type="text" name="title" autocomplete="off" placeholder="请输入任务标题" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">任务简介</label>
                                <div class="layui-input-block">
                                    <textarea name="content" placeholder="请输入任务简介" class="layui-textarea"></textarea>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">悬赏单价</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="reward_price" value="10" autocomplete="off" placeholder="请输入悬赏单价" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">领取数量</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="total_number" value="1" autocomplete="off" placeholder="请输入领取数量" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">领取次数</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="person_time" value="1" autocomplete="off" placeholder="请输入领取次数" class="layui-input">
                                </div>
                                <div class="layui-form-mid layui-word-aux">次/人</div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">任务总价</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="total_price" value="10" autocomplete="off" placeholder="请输入任务总价" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">是否必领</label>
                                <div class="layui-input-block">
                                    <input type="radio" name="is_b" value="1" title="是">
                                    <input type="radio" name="is_b" value="2" title="否" checked>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">链接信息</label>
                                <div class="layui-input-block">
                                    <input type="text" name="link_info" value="" autocomplete="off" placeholder="请输入链接信息" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">任务级别</label>
                                <div class="layui-input-block">
                                    {foreach $userLevel as $key=>$value}
                                    <input type="radio" name="task_level" value="{$value.grade}" title="{$value.name}"{if reset($userLevel) eq $value} checked{/if}>
                                    {/foreach}
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">截止日期</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="end_time" autocomplete="off" placeholder="请选择截止日期" class="layui-input" readonly>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">完成条件</label>
                                <div class="layui-input-block">
                                    <input type="checkbox" name="finish_condition[0]" title="手机认证">
                                    <input type="checkbox" name="finish_condition[1]" title="微信认证">
                                    <input type="checkbox" name="finish_condition[2]" title="实名认证">
                                    <input type="checkbox" name="finish_condition[3]" title="身份认证">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">上传要求</label>
                                <div class="layui-input-block">
                                    <textarea name="requirement" placeholder="请输入上传要求" class="layui-textarea"></textarea>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">审核样例</label>
                                <div class="layui-upload layui-input-block">
                                    <button type="button" class="layui-btn layui-btn-normal examine_demo">选择多文件</button>
                                    <div class="layui-form-mid layui-word-aux" style="float: right;">此项如不修改请不要上传文件，否则将覆盖原数据</div>
                                    <div class="layui-upload-list">
                                        <table class="layui-table">
                                        <thead>
                                            <tr>
                                                <th>图片预览</th>
                                                <th>状态</th>
                                                <th>操作</th>
                                            </tr>
                                        </thead>
                                        <tbody id="demoList"></tbody>
                                        </table>
                                    </div>
                                    <button type="button" class="layui-btn" id="examine-demo-btn">开始上传</button>
                                </div>
                            </div>
                            <div class="layui-form-item step-holder" data-len="1">
                                <label class="layui-form-label">任务步骤</label>
                                <div class="layui-input-block" style="border: 1px solid #d2d2d2;border-radius: 3px;padding: 12px;display: flex;margin-bottom: 10px;align-items: flex-start;">
                                    <h4 style="background-color: #FFB800;width: 40px;height: 40px;border-radius: 20px;line-height: 40px;font-size: 16px;margin-right: 10px;text-align: center;margin-top: 50px;">1</h4>
                                    <div class="layui-upload-drag task-step" id="task-step-1" style="width: 10%;margin-right: 10px;">
                                        <i class="layui-icon layui-icon-upload"></i>
                                        <p>点击上传，或将文件拖拽到此处</p>
                                        <div class="layui-hide">
                                            <hr>
                                            <img src="" alt="上传成功后渲染" style="max-width: 100%">
                                            <p></p>
                                        </div>
                                    </div>
                                    <input type="hidden" name="task_step[0][img]" value="" class="layui-input">
                                    <textarea name="task_step[0][describe]" placeholder="请输入步骤描述" class="layui-textarea" style="width: 70%;display: inline-block;height: 250px;"></textarea>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label"></label>
                                <div class="layui-input-block">
                                    <button type="button" class="layui-btn layui-btn-sm layui-btn-warm step-holder-add">
                                        <i class="layui-icon layui-icon-addition" style="font-size: 20px;"></i>
                                    </button>
                                    <button type="button" class="layui-btn layui-btn-sm layui-btn-warm step-holder-del">
                                        <i class="layui-icon layui-icon-subtraction" style="font-size: 20px;"></i>
                                    </button>
                                </div>
                            </div>
                            -->
                            <div class="layui-form-item" style="margin-top: 40px;text-align: center;">
                                <input type="hidden" name="nft_id" value="{$nftInfo.id}" autocomplete="off" class="layui-input">
                                <button class="layui-btn" lay-submit lay-filter="task_add" data-type="taskAdd">立即提交</button>
                                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>

<script src="/resource/layuiadmin/layui/layui.js"></script>
<script src="/resource/js/manage/init_date.js"></script>
<script>
    layui.use(['layer', 'element', 'form', 'upload', 'table', 'laydate'], function() {
        var $ = layui.$
            , element = layui.element
            , layer = layui.layer
            , form = layui.form
            , upload = layui.upload
            , table = layui.table
            , laydate = layui.laydate;

        // 提交任务
        form.on('submit(task_add)', function(data){
            $.ajax({
                url: "/manage/bet/taskAdd",
                data: data.field,
                type: "POST",
                dataType: "json",
                timeout: 15000,
                beforeSend: function(){
                    layer.load(1);
                },
                success: function(msg){
                    var alertStr = (msg == 1) ? '操作成功' : msg;
                    layer.msg(alertStr, {time: 2000}, function(){
                        if(msg==1){
                            parent.layer.closeAll();
                            parent.layui.table.reload('nft');
                        }
                    });
                },
                complete: function(){
                    layer.closeAll("loading");
                }
            });
            return false;
        });
    })
</script>
</body>
</html>
